{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 安装腾讯云sdk"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting tencentcloud-sdk-python\n",
      "  Downloading https://files.pythonhosted.org/packages/75/b1/16bc0ff4d34729fc6c0b9eedeadfdbc148b5eee4ee7de55d67157d732639/tencentcloud_sdk_python-3.0.222-py2.py3-none-any.whl (2.0MB)\n",
      "Installing collected packages: tencentcloud-sdk-python\n",
      "Successfully installed tencentcloud-sdk-python-3.0.222\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "You are using pip version 9.0.3, however version 20.1.1 is available.\n",
      "You should consider upgrading via the 'python -m pip install --upgrade pip' command.\n"
     ]
    }
   ],
   "source": [
    "!pip install tencentcloud-sdk-python"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 测试代码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"Keywords\": [{\"Score\": 1.0, \"Word\": \"北京\"}, {\"Score\": 1.0, \"Word\": \"科技馆\"}], \"RequestId\": \"010ecaa7-1ceb-4deb-b2b6-a480ae0b1d2f\"}\n"
     ]
    }
   ],
   "source": [
    "from tencentcloud.common import credential\n",
    "from tencentcloud.common.profile.client_profile import ClientProfile\n",
    "from tencentcloud.common.profile.http_profile import HttpProfile\n",
    "from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException \n",
    "from tencentcloud.nlp.v20190408 import nlp_client, models \n",
    "try: \n",
    "    cred = credential.Credential(\"AKIDtXCerXuJMExqiKJKTM7ejkU0GG0ZN37v\", \"xf7J2Ws873kCOL3dnhfzi0VklW1F6i4A\") \n",
    "    httpProfile = HttpProfile()\n",
    "    httpProfile.endpoint = \"nlp.tencentcloudapi.com\"\n",
    "\n",
    "    clientProfile = ClientProfile()\n",
    "    clientProfile.httpProfile = httpProfile\n",
    "    client = nlp_client.NlpClient(cred, \"ap-guangzhou\", clientProfile) \n",
    "\n",
    "    req = models.KeywordsExtractionRequest()\n",
    "    params = '{\\\"Text\\\":\\\"北京科技馆\\\"}'\n",
    "    req.from_json_string(params)\n",
    "\n",
    "    resp = client.KeywordsExtraction(req) \n",
    "    print(resp.to_json_string()) \n",
    "\n",
    "except TencentCloudSDKException as err: \n",
    "    print(err) "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
